package com.springboot.cloud.demos.ribbon.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.DictionaryForm;
import com.springboot.cloud.demos.entity.po.Dictionary;
import com.springboot.cloud.demos.ribbon.service.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class DictionaryController {

    @Autowired
    private DictionaryService dictionaryService;

    @GetMapping("/dictionary/query")
    public  Result<List<Dictionary>> query(@RequestParam("keyNo") String keyNo) {
        return dictionaryService.query(keyNo);
    }
    @GetMapping("/dictionary")
    public  Result<List<Dictionary>> list() {
        return dictionaryService.list();
    }

    @PostMapping("/dictionary")
    public Result add(@RequestBody DictionaryForm dictionaryForm) {
        return dictionaryService.save(dictionaryForm);
    }

    @GetMapping("/dictionary/{id}")
    public Result get(@PathVariable(value = "id") String id) {
        return dictionaryService.get(id);
    }
}
